#!/usr/bin/python
import MySQLdb, sys

def req(r,db):
    cur = db.cursor()
    cur.execute(r)
    while (1):
        row = cur.fetchone()
        if row == None:
            break
        print row
    print "Number of rows returned : %d" % cur.rowcount


try:
    db = MySQLdb.connect("localhost", "root", "asg09", "asg09")
except MySQLdb.Error, e:
    print "Error : Connection to data base failed (e.args[0], e.args[1])"
    sys.exit(1)

req("select * from user",db) 
req("insert into user values('fab', 'asg09', 'fab@asg09.com', 2, 'Montpellier', 'France')", db)
req("select * from user",db) 
#cur.close()
db.close()

